package com.game.worm.mobile.view.discovery.group;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.dx.as.ToolBarOptions;
import com.dx.as.UI;
import com.game.worm.mobile.R;
import com.game.worm.mobile.view.discovery.group.adpater.ArticleAdpater;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by d_xxiang on 2018/4/7.
 */

public class ArticleActivity extends UI{
    public final static int Article_User = 1001;
    public final static int Article_Official = 1002;
    public final static String Article_Type = "article_type";

    private ArticleAdpater adpater;
    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_discovery_group);
        initView();
        initToolbar();
    }

    public void initToolbar(){

        int type = getIntent().getIntExtra(Article_Type,Article_User);

        ToolBarOptions toolBarOptions = new ToolBarOptions();
        toolBarOptions.showLeftImg = true;
        toolBarOptions.showRightImg = true;

        if (type == Article_User){
            toolBarOptions.titleId = R.string.my_game_group;
            toolBarOptions.rightDrawImgId = R.drawable.ico_create_article;
            toolBarOptions.onRightImgClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                }
            };
        }else {
            toolBarOptions.titleId = R.string.Official;
        }

        setToolbar(toolBarOptions);
    }

    private void initView(){
        RecyclerView recyclerView = findView(R.id.recyclerview);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);

        adpater = new ArticleAdpater(this);
        recyclerView.setAdapter(adpater);
        getTestData();
    }

    private void getTestData(){
        List<ArticleBean> list = new ArrayList<>();

        for (int i = 0; i < 5 ; i ++ ){
            list.add( new ArticleBean());
        }
        adpater.setData(list);
        adpater.notifyDataSetChanged();
    }
}
